import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const defaultRouterMap = [{
  path: '/',
  redirect: '/home'
},
{
  path: '/login',
  component: () => import('@/views/Login.vue')
},
{
  path: '/home',
  name: 'home',
  component: () => import('@/layout/Container.vue'),
  children: [{
    path: 'welcome',
    component: () => import('../views/Welcome.vue')
  },
  {
    path: '/home',
    redirect: 'welcome'
  }]
},
{
  path: '/liveDetail/:id',
  component : ()=> import('@/views/Livedetail.vue'),
  meta: {
    title: '直播详情',
    isHidden: true ,
    icon: '',
    roles: ['admin']
  }
},
]

// 需要权限的路由
export const roleRouterMap = [

  {
    path: 'housing',
    component: () => import('@/views/Housing.vue'),
    meta: {
      title: '房源管理',
      icon: 'el-icon-menu',
      roles: ['admin', 'editor']
    }
  },
  {
    path: 'live',
    component: () => import('@/views/Live.vue'),
    meta: {
      title: '直播管理',
      icon: 'el-icon-video-camera',
      roles: ['admin']
    }
  },
  {
    path: 'groupon',
    component: () => import('@/views/Groupon.vue'),
    meta: {
      title: '团购管理',
      icon: 'el-icon-s-shop',
      roles: ['admin', 'editor']
    }
  },
  {
    path: 'audit',
    component: () => import('@/views/Audit.vue'),
    meta: {
      title: '审核管理',
      icon: 'el-icon-s-check',
      roles: ['admin']
    }
  },
  {
    path: 'order',
    component: () => import('@/views/Order.vue'),
    meta: {
      title: '订单管理',
      icon: 'el-icon-s-order',
      roles: ['admin']
    }
  },
  {
    path: 'information',
    component: () => import('@/views/Information.vue'),
    meta: {
      title: '资讯管理',
      icon: 'el-icon-s-promotion',
      roles: ['admin', 'editor']
    }
  },
  {
    path: 'broker',
    component: () => import('@/views/Broker.vue'),
    meta: {
      title: '经纪人管理',
      icon: 'el-icon-s-custom',
      roles: ['admin']
    }
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: defaultRouterMap
})

export default router
